import React, { Component } from 'react';
import { Form, Row, Col } from 'antd';
import ShowType from '../Common/CommonComponent';
import styles from '../../index.less';
import * as commonUtils from '../../utils/utils';

const FormItem = Form.Item;

class TabFinanceOfferComponent extends Component {
  constructor(props) {
    super(props);
    this.state = {
    };
  }
  getShowTypeProps = (sName) => {
    const { masterConfig, masterData } = this.props;
    if (commonUtils.isNotEmptyObject(masterConfig) && commonUtils.isNotEmptyObject(masterData)) {
      /*   配置信息   */
      const showConfig = this.getShowConfig(sName);
      /*   返回值   */
      return {
        form: this.props.form,
        getSqlDropDownData: this.props.getSqlDropDownData,
        handleSqlDropDownNewRecord: this.props.handleSqlDropDownNewRecord,
        getFloatNum: this.props.getFloatNum,
        onChange: this.props.onChange, /*   表单数据改变事件方法(数据格式:函数)   */
        showConfig, /*   关于本showType相关配置(数据格式:对象)   */
        enabled: this.props.enabled && !showConfig.bReadonly, /*   是否是查看状态(数据格式:布尔)   */
        dataValue: masterData[sName], /*   本showType数据(数据格式:对象)   */
        bTable: false, /*   是否为表格数据   */
      };
    }
  };
  /**   获取showConfig   */
  getShowConfig = (sName) => {
    /*   通过sName过滤出对应的showConfig   */
    const showConfigArr = this.props.masterConfig.gdsconfigformslave.filter(item => item.sControlName === sName && item.bVisible);
    if (commonUtils.isNotEmptyArr(showConfigArr)) {
      showConfigArr[0].sName = showConfigArr[0].sControlName;
      return showConfigArr[0];
    }
    /*   返回值   */
    return {};
  };
  render() {
    const { masterConfig, masterData } = this.props;
    return (
      <FormItem className={styles.searchSlaveForm}>
        {commonUtils.isEmptyObject(masterConfig) || commonUtils.isEmptyObject(masterData) ? '' :
        <Row type="flex" justify="space-between">
          <Col span={11}>
            <div className={styles.tabChild}>
              <div className={styles.tabChildTitle}>
                <span>{this.props.masterConfig.gdsconfigformslave.filter(item => (item.sControlName.toLowerCase() === 'tabfinancecontrol'))[0].showName}</span>
              </div>
              <Row type="flex" justify="space-between">
                <Col span={11}>
                  <ShowType {...this.getShowTypeProps('sCbxPayablesType')} />
                  <ShowType {...this.getShowTypeProps('sCbxOutSidePayType')} />
                  <ShowType {...this.getShowTypeProps('sCbxReceivablesType')} />
                  <ShowType {...this.getShowTypeProps('sCbxBusinessType')} />
                  <ShowType {...this.getShowTypeProps('sCbxAdvanceType')} />
                </Col>
                <Col span={11}>
                  <ShowType {...this.getShowTypeProps('sCbxGetPayStandard')} />
                  <ShowType {...this.getShowTypeProps('sCbxMaterialsCostMode')} />
                  <ShowType {...this.getShowTypeProps('iNetMoneyInaccuracies')} />
                </Col>
              </Row>
              <Row type="flex" justify="space-between">
                <Col span={11}>
                  <ShowType {...this.getShowTypeProps('bCkxStrictPlanPrchasePrice')} />
                  <ShowType {...this.getShowTypeProps('bCkxMaterialsTax')} />
                </Col>
                <Col span={11}>
                  <ShowType {...this.getShowTypeProps('bCkxARExceed')} />
                  <ShowType {...this.getShowTypeProps('bCkxWebNotInFinance')} />
                </Col>
              </Row>
            </div>
          </Col>
          <Col span={11}>
            <div className={styles.tabChild}>
              <div className={styles.tabChildTitle}>
                <span>{this.props.masterConfig.gdsconfigformslave.filter(item => (item.sControlName.toLowerCase() === 'taboffer'))[0].showName}</span>
              </div>
              <Row type="flex" justify="space-between">
                <Col span={11}>
                  <ShowType {...this.getShowTypeProps('iNetIntervalDays')} />
                  <ShowType {...this.getShowTypeProps('sCbxOfferMaterials')} />
                </Col>
                <Col span={11}>
                  <ShowType {...this.getShowTypeProps('sCbxProcessPrice')} />
                  <ShowType {...this.getShowTypeProps('iNetVeryHighPercentage')} />
                </Col>
              </Row>
              <Row type="flex" justify="space-between">
                <Col span={11}>
                  <ShowType {...this.getShowTypeProps('bCkxOfferFunctionality')} />
                </Col>
                <Col span={11}>
                  <ShowType {...this.getShowTypeProps('bCkxNoTaxProcessPrice')} />
                </Col>
              </Row>
            </div>
          </Col>
          <Col span={24}>
            <div className={styles.tabChild}>
              <div className={styles.tabChildTitle}>
                <span>{this.props.masterConfig.gdsconfigformslave.filter(item => (item.sControlName.toLowerCase() === 'tabinventorycontrol'))[0].showName}</span>
              </div>
              <Row type="flex" justify="space-between">
                <Col span={11}>
                  <Row type="flex" justify="space-between">
                    <Col span={11}>
                      <ShowType {...this.getShowTypeProps('sCbxMaterialsDefine')} />
                      <ShowType {...this.getShowTypeProps('sCbxSemigoodsDefine')} />
                    </Col>
                    <Col span={11}>
                      <ShowType {...this.getShowTypeProps('sCbxProductDefine')} />
                    </Col>
                  </Row>
                  <Row type="flex" justify="space-between">
                    <Col span={11}>
                      <ShowType {...this.getShowTypeProps('sCbxCorrugateWidth')} />
                      <ShowType {...this.getShowTypeProps('sCbxCorrugateLength')} />
                    </Col>
                    <Col span={11}>
                      <ShowType {...this.getShowTypeProps('iNetCorrugateWidthSubtract')} />
                      <ShowType {...this.getShowTypeProps('iNetCorrugateLengthSubtract')} />
                    </Col>
                  </Row>
                </Col>
                <Col span={11}>
                  <Row type="flex" justify="space-between">
                    <Col span={11}>
                      <ShowType {...this.getShowTypeProps('bCkxSemigoodsStockLimit')} />
                      <ShowType {...this.getShowTypeProps('bCkxMaterialsStockLimit')} />
                      <ShowType {...this.getShowTypeProps('bCkxProductStockLimit')} />
                      <ShowType {...this.getShowTypeProps('bCkxNotStockDeletingMaterial')} />
                    </Col>
                    <Col span={11}>
                      <ShowType {...this.getShowTypeProps('bCkxMaterialsStockPostLimit')} />
                      <ShowType {...this.getShowTypeProps('bCkxWharehouseLimit')} />
                      <ShowType {...this.getShowTypeProps('bCkxBuSampleNoDeliver')} />
                      <ShowType {...this.getShowTypeProps('bCkxReelPaper')} />
                    </Col>
                  </Row>
                </Col>
              </Row>
            </div>
          </Col>
        </Row>
        }
      </FormItem>
    );
  }
}

export default TabFinanceOfferComponent;
